package com.tedu.ds.order.controller;

import com.sun.org.apache.xpath.internal.operations.Or;
import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.order.pojo.dto.OrderQuery;
import com.tedu.ds.order.pojo.dto.OrderSaveParam;
import com.tedu.ds.order.pojo.vo.OrderVO;
import com.tedu.ds.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/order")
@Api(tags = "订单模块")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody OrderSaveParam orderSaveParam){
        orderService.save(orderSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    @ApiOperation("删除功能")
    public JsonResult deleteById(@PathVariable Long id){
        orderService.deleteById(id);
        return JsonResult.ok();
    }
    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody OrderQuery orderQuery){
        List<OrderVO> list = orderService.select(orderQuery);
        return JsonResult.ok(list);
    }

    @PutMapping("/updateStatus")
    @ApiOperation("更新状态")
    public JsonResult updateStatus(@RequestBody OrderSaveParam orderSaveParam){
        orderService.updateStatus(orderSaveParam);
        return JsonResult.ok();
    }

    


}
